<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page isELIgnored="false" %>
<html>
<head>
    <title>登录</title>
    <link href="${pageContext.request.contextPath}/static/css/loginStyle.css" rel='stylesheet' type='text/css' />
    <link rel="icon" href="${pageContext.request.contextPath}/static/imags/logo.png" type="image/x-icon">
    <style>
        body{
            background-image: url("${pageContext.request.contextPath}/static/imags/wallhaven-4ymjxx_1600x900.png");
        }
    </style>
</head>
<body>
<div class="main">
    <div class="login">
        <h1>后台管理系统</h1>
        <div class="inset">
            <!--start-main-->
            <form method="post" action="${pageContext.request.contextPath}/login/check">
                <div>
                    <h2>管理登录</h2>
                    <span><label>用户名</label></span>
                    <span><input name="username" type="text" class="textbox" required ></span>
                </div>
                <div>
                    <span><label>密码</label></span>
                    <span><input name="password" type="password" class="password" required></span>
                </div>
                <div>
                    <span><label>验证码</label></span>
                    <span><input name="checkcode" type="text" class="checkcode" required><img id="checkcodeImg" onclick="getImg()" class="checkcodeImg" src="${pageContext.request.contextPath}/checkcode/getImg?a=1"></span>
                </div>
                <div style="width: 100%; height: 28px; margin-top: 50px; text-align: center; color: red;">
                    ${msg}
                </div>
                <div class="sign">
                    <input type="submit" value="登录" class="submit" />
                </div>
            </form>
        </div>
    </div>
    <!--//end-main-->
</div>

<script src="${pageContext.request.contextPath}/static/js/jquery-3.6.0.js"></script>
<script>
    function getImg() {
        document.getElementById('checkcodeImg').setAttribute('src', 'http://localhost:8080/checkcode/getImg?a='+Math.random()*100);
    }

    // // 登录
    // $('#submit').click(function () {
    //     var checkModel = {
    //         username: $('#username').val(),
    //         password: $('#password').val(),
    //         checkcode: $('#checkcode').val()
    //     }
    //     var jsonData = JSON.stringify(checkModel);
    //     // alert(jsonData);
    //     $.ajax({
    //         type: "POST",
    //         url: "http://localhost:8080/login/check",
    //         data: jsonData,
    //         contentType: "application/json",
    //         dataType: "string",
    //         success: function (data) {
    //             alert(data);
    //             $('#errorMsg').innerText(data);
    //         }
    //     });
    //     return false;
    // });
</script>
</body>
</html>
